import pytest
from selenium import webdriver
from selenium.webdriver.chrome.service import Service

from config import BASE_DIR


@pytest.fixture
def driver():
    #无头模式  --->目的：减少测试用例的执行时间
    # options = webdriver.EdgeOptions()
    options = webdriver.ChromeOptions()
    # options.add_argument('headless')#浏览器不提供可视化界面 --->无头模式
    options.add_argument('--disable-gpu') #禁用 GPU
    options.add_argument('--no-sandbox') #沙箱模式
    # options.add_argument('--disable-dev-shm-usage') #禁用f12
    # options=options 配置生效
    # 配置谷歌浏览器驱动程序
    # executable_path=BASE_DIR+"/driver/chromedriver.exe"
    # service = Service(executable_path=executable_path)
    # driver = webdriver.Chrome(options=options,service=service)
    # driver = webdriver.Chrome(service=service)
    driver = webdriver.Edge()
    driver.maximize_window()
    yield   driver

    driver.quit()